//
//  BaseTabBarController.m
//  RWDYTV
//
//  Created by 任伟 on 16/1/25.
//  Copyright © 2016年 任伟. All rights reserved.
//

#import "BaseTabBarController.h"
#import "BaseNaviController.h"
#import "RecommendController.h"
#import "ColumnController.h"
#import "OnlineViewController.h"
#import "MineController.h"
#import "Public.h"

@interface BaseTabBarController ()

@end

@implementation BaseTabBarController

- (void)viewDidLoad {
    [super viewDidLoad];

    UIView *backView = [[UIView alloc] initWithFrame:self.view.frame];
    backView.backgroundColor = [UIColor whiteColor];
    [self.tabBar insertSubview:backView atIndex:0];
    self.tabBar.opaque = YES;
    
    self.tabBar.tintColor = [UIColor colorWithRed:244/255.0f green:89/255.0f blue:27/255.0f alpha:1.0f];
    
    [self initChildViewControllers];
}

/// 加载自控制器
- (void)initChildViewControllers {
    
    NSMutableArray *childVCArray = [[NSMutableArray alloc] initWithCapacity:4];

    RecommendController *recommendVC = [[RecommendController alloc] init];
    [recommendVC.tabBarItem setTitle:@"推荐"];
    [recommendVC.tabBarItem setImage:[UIImage imageNamed:@"btn_home_normal"]];
    [recommendVC.tabBarItem setSelectedImage:[UIImage imageNamed:@"btn_home_selected"]];
    BaseNaviController *recommendNav = [[BaseNaviController alloc] initWithRootViewController:recommendVC];
    [childVCArray addObject:recommendNav];
    
    ColumnController *columnVC = [[ColumnController alloc] init];
    [columnVC.tabBarItem setTitle:@"栏目"];
    [columnVC.tabBarItem setImage:[UIImage imageNamed:@"btn_column_normal"]];
    [columnVC.tabBarItem setSelectedImage:[UIImage imageNamed:@"btn_column_selected"]];
    BaseNaviController *columnNav = [[BaseNaviController alloc] initWithRootViewController:columnVC];
    [childVCArray addObject:columnNav];
    
    OnlineViewController *onlineVC = [[OnlineViewController alloc] init];
    [onlineVC.tabBarItem setTitle:@"直播"];
    [onlineVC.tabBarItem setImage:[UIImage imageNamed:@"btn_live_normal"]];
    [onlineVC.tabBarItem setSelectedImage:[UIImage imageNamed:@"btn_live_selected"]];
    BaseNaviController *onlineNav = [[BaseNaviController alloc] initWithRootViewController:onlineVC];
    [childVCArray addObject:onlineNav];
    
    MineController *mineVC = [[MineController alloc] init];
    [mineVC.tabBarItem setTitle:@"我的"];
    [mineVC.tabBarItem setImage:[UIImage imageNamed:@"btn_user_normal"]];
    [mineVC.tabBarItem setSelectedImage:[UIImage imageNamed:@"btn_user_selected"]];
    BaseNaviController *mineNav = [[BaseNaviController alloc] initWithRootViewController:mineVC];
    [childVCArray addObject:mineNav];
    
    [self setViewControllers:childVCArray];
    
}

@end
